<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1">
		<title>CRM</title>
		<link rel="stylesheet" type="text/css" href="../static/azxcrm/css/wap/aui.css" th:href="@{/azxcrm/css/wap/aui.css}" />
		<link rel="stylesheet" type="text/css" href="../static/azxcrm/css/wap/unorder.css" th:href="@{/azxcrm/css/wap/unorder.css}" />
		<link rel="stylesheet" type="text/css" href="../static/azxcrm/css/wap/aui.css" th:href="@{/azxcrm/css/wap/mui.min.css}" />
        <link rel="stylesheet" type="text/css" href="../static/azxcrm/css/wap/aui.css" th:href="@{/azxcrm/css/wap/mui.picker.min.css}" />
        <link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_835360_8flqp9ignrc.css"/>
        <script src="/azxcrm/js/wap/mui.min.js" th:src="@{/azxcrm/js/wap/mui.min.js}" type="text/javascript" charset="utf-8"></script>
        <script src="/azxcrm/js/wap/mui.picker.min.js" th:src="@{/azxcrm/js/wap/mui.picker.min.js}" type="text/javascript" charset="utf-8"></script>
		<script src="../static/js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
        <script th:inline="javascript"> var ctx = [[@{/}]]; </script>		
	</head>
	<body>
  	<!--头部结构-->
	<div class="g-head">
	    <header class="aui-bar aui-bar-nav">
			<a class="aui-pull-left aui-btn"  href="javascript:history.go(-1)">
			    <span class="iconfont icon-fanhui1"></span>返回
			</a>
			<div class="aui-title">未成单原因填写</div>
		</header>
	</div>
    <!--头部结构-->
    
    <!--订单编写结构-->
    <div class="aui-content aui-margin-b-15">
	    <ul class="aui-list aui-list-in">
	        <li class="aui-list-item">
	            <div class="s-order">
	                <div>订单编号：</div>
	                <div th:text="${order.orderNum}"></div>
	            </div>
	        </li>
	        <li class="aui-list-item">
	            <div class="s-order">
	                <div>订单类型：</div>
	                <div th:text="${order.typeName}"></div>
	            </div>
	        </li>
	    </ul>
	</div>
     <!--订单编写结构-->

     <!--客户信息结构-->
     <div class="aui-content aui-margin-b-15 g-order">
	    <ul class="aui-list aui-list-in">
	        <li class="aui-list-header">
	        	<div class="s-order">
	        		<div><img src="../azxcrm/image/wap/customer.png"/></div>
	        		<div>客户信息</div>
	        	</div>
	        </li>
	        <li class="aui-list-item">
	            <div class="s-order">
	                <div>客户姓名：</div>
	                <div th:text="${order.customerClue.customerName}"></div>
	            </div>
	        </li>
	        <li class="aui-list-item">
	            <div class="s-order">
	                <div>手机号码：</div>
	                <div th:text="${order.customerClue.customerCellphone}"></div>
	            </div>
	        </li>
	    </ul>
	</div> 	
     <!--客户信息结构-->
     
    <!--未成单结构-->
    <form id="form-orderReason">
	<div class="aui-content aui-margin-b-15 g-order2">
		<ul class="aui-list aui-form-list">
	        <li class="aui-list-header">
				<div class="s-order">
					<div><img src="../azxcrm/image/wap/error.png"/></div>
					<div>未成单原因填写</div>
				</div>
	        </li>
			<li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-input">
                        <textarea placeholder="请填写未成单原因" id="unformedCause" name="unformedCause"></textarea>
                    </div>
                </div>
            </li>
	    </ul>
	</div>
	<!--未成单结构-->

	<!--按钮结构-->
	<footer class="aui-bar aui-bar-tab" id="footer">
	    <a class="aui-bar-tab-item">                   
	        <div class="aui-bar-tab-label">
	        <input type="hidden" id="orderId" name="orderId" th:value="${order.orderId}">
	        <input type="hidden" id="status" name="status" th:value="${status}">
	        <input type="hidden" id="dispatchId" name="dispatchId" th:value="${dispatchId}">
	        <input type="button" th:value="提交" class="btn btn-warning dropdown-toggle" onclick="return check()" >
	        </div>
	    </a>           
   </footer>
   </form>	
	<!--按钮结构-->
	</body>
</html>
<script>
function check() {  
    var orderId = document.getElementById('orderId').value;
    var status = document.getElementById('status').value;
    var dispatchId = document.getElementById('dispatchId').value;
    var unformedCause = document.getElementById('unformedCause').value;
    $.ajax({
        cache : true,
        type : "POST",
        url : ctx + "/wap/wapOrderReasonSave?orderId="+orderId,
        data : $("#form-orderReason").serialize(),
        async : false,
        error : function(request) {
        	mui.toast("系统错误", "error");
        },
        success : function(data) {
                   if (data.code == 0) {                	   
                        mui.toast("添加成功"); 
                        if(status==0){
                       	$("#toastBtn").removeAttr("onclick");
                            setTimeout(function(){
                            	window.location.href= ctx + "indexWap"
                                },2200)
                        }else if(status == 1){
                       	 $("#toastBtn").removeAttr("onclick");
                       	 setTimeout(function(){
                                window.location.href= ctx + "wap/order/followOrder"
                                },2200)
                        }
                    } else {
                        mui.toast("添加失败");
                 } 
          }
    });
}

</script>
